<?php

namespace My\Model;

use Utuo\UtuoModel;

class WechatMaterialModel extends UtuoModel {
	// 素材类型
	public $materialTypes = array(
			'news' => '图文素材',
			'url' => '链接素材' 
	);
	
	// 自动验证
	protected $_validate = array(
			array('title', 'require', '素材标题不能为空'),
			array('cover_url', 'require', '素材地址不能为空'),
	);
	
	// 客户id
	public function getNewsList($cid){
		$p = I('get.p', 1, 'intval');
		$pageSize = 10;
		$d = M("WechatMaterial")->field("id,title,cover_url")->where(array(
				'cid' => $cid,
				'is_deleted' => 0
		));
		$materialLists = $d->limit(($p - 1) * $pageSize . ',' . $pageSize)->order("id desc")->select();
		return $materialLists;
	}

}